import {
  IsString,
  IsNotEmpty,
  IsOptional,
  IsEnum,
  IsBoolean,
  IsNumber,
  IsDate,
  IsObject,
} from 'class-validator';
import { Type } from 'class-transformer';

// 状态：0-删除，1-未发布，2-发布，3-管理员强制下线
export enum WorkStatus {
  Deleted = 0,
  Unpublished = 1,
  Published = 2,
  ForceOffline = 3,
}

export class CreateWorkDto {
  @IsString()
  @IsNotEmpty()
  readonly title: string;

  @IsString()
  @IsOptional()
  readonly desc?: string;

  @IsObject()
  @IsOptional()
  readonly content?: any; // 或定义为 IworkContent 类型

  @IsString()
  @IsOptional()
  readonly coverImg?: string;

  @IsEnum(WorkStatus)
  readonly status: WorkStatus;

  @IsBoolean()
  @IsOptional()
  readonly isTemplate?: boolean;

  @IsBoolean()
  @IsOptional()
  readonly isHot?: boolean;

  @IsNumber()
  @IsOptional()
  readonly copiedCount?: number;

  @IsBoolean()
  @IsOptional()
  readonly isPublic?: boolean;

  @IsOptional()
  @Type(() => Date)
  @IsDate()
  readonly latestPublishAt?: Date;
}
